﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web;
using System.Web.Http;
using ZHDJ.AppInterface.Common;
using ZHDJ.AppInterface.Models;
using ZHDJ.Core;

namespace ZHDJ.AppInterface.Controllers
{
    /// <summary>
    /// 支部活动
    /// </summary>
    public class BranchActivitieController : ApiController
    {
        #region 获取支部活动
        [HttpPost]
        public ReturnResult GetBranchActivity(dynamic obj)
        {
            int pageIndex = Convert.ToInt32(obj.pageIndex);
            int pageSize = Convert.ToInt32(obj.pageSize);
            string loginId = Convert.ToString(obj.loginId);
            string branchId = Convert.ToString(obj.branchId);
            DataTable dt = InterfaceHelper.GetBranchActivity(pageIndex, pageSize, loginId, branchId).Tables[0];
            IList<PartyBranchActivitie> list = DataTableToListModel<PartyBranchActivitie>.ConvertToModel(dt);

            return new ReturnResult()
            {
                code = "200",
                result = list,
                msg = ""
            };
        }
        #endregion

        #region 获取支部活动实体
        /// <summary>
        /// 获取支部活动实体
        /// </summary>
        /// <param name="obj">参数</param>
        /// <returns></returns>
        [HttpPost]
        public ReturnResult GetBranchActivityModel(dynamic obj)
        {
            string ID = Convert.ToString(obj.ID);
            PartyBranchActivitie model = InterfaceHelper.GetBranchActivityModel(ID);
            return new ReturnResult()
            {
                code = "200",
                result = model,
                msg = "success"
            };
        }
        #endregion

        #region 获取活动数量
        [HttpPost]
        public ReturnResult GetBranchActivityCount(dynamic obj)
        {
            string loginId = Convert.ToString(obj.loginId);
            string branchId = Convert.ToString(obj.branchId);
            int IsEnd = Convert.ToInt32(obj.IsEnd);
            int num = InterfaceHelper.GetBranchActivityCount(loginId, branchId, IsEnd);

            return new ReturnResult()
            {
                code = "200",
                result = num,
                msg = "success"
            };
        }
        #endregion
    }
}
